
import {fork, put,take,takeEvery,call,cps,all,cancel} from './redux-saga/effects';
import * as actionTypes from './action-types';

function delay(ms) {
    return new Promise((resolve) => {
        setTimeout(resolve, ms);
    });
}

function* add(){
    while (true) {
        yield delay(1000);
        yield put({ type: actionTypes.ADD });
    }
}

function* addWatcher(){
    const task = yield fork(add)
    console.log(task);
    yield take(actionTypes.STOP)
    yield cancel(task);
}

export default function* rootSaga() {
    yield addWatcher()
}